# TODO: 饼图
# DATE: 2022/3/30
# AUTHOR: Cheng Ze WUST
import numpy as np
import matplotlib.pyplot as plt

m = 51212
f = 40742
m_perc = m / (m + f)
f_perc = f / (m + f)
colors = ['navy', 'lightcoral']
labels = ['Male', 'Female']
plt.figure(figsize=(6, 6))
paches, texts, autotexts = plt.pie([m_perc, f_perc], labels=labels, autopct='%1.1f%%', explode=[0, 0.02], colors=colors)
for text in texts + autotexts:
    text.set_fontsize(16)
for text in autotexts:
    text.set_color('white')
plt.title('Fig1')
plt.show()


# region 子图布局
ax1 = plt.subplot2grid((3, 3), (0, 0))
ax2 = plt.subplot2grid((3, 3), (1, 0))
ax3 = plt.subplot2grid((3, 3), (0, 2), rowspan=3)
ax4 = plt.subplot2grid((3, 3), (2, 0), colspan=2)
ax5 = plt.subplot2grid((3, 3), (0, 1), rowspan=2)
plt.title('Fig2')
plt.show()
# endregion



